import request from "../utils/request";
export function login({ username, password }) {
  return request({
    url: "/login",
    method: "post",
    data: {
      username,
      password,
    },
  });
}
export function getMenus(){
    return request({
        url:'/menus',
    })
}

//获取用户信息
export function getUser({pagenum,pagesize,query}){
  return request({
    url: "/users",
    params:{
      pagenum,
      pagesize,
      query,
    }
  });
}

//添加用户
export function addUsers({username,password,email,mobile}){
  return request ({
    url:"/users",
    method:"post",
    data:{
      username,
      password,
      email,
      mobile
    }
  })
}

//查看用户
export function getUsers(id){
  return request({
    url: `/users/${id}`,
    method:'get',
  });
}

//修改用户
export function editUsers(id,{email,mobile}){
  return request({
    url:`/users/${id}`,
    method:"put",
    data:{
      email,
      mobile,
    }
  })
}
//修改用户状态
export function editState(uId,type){
  return request({
    url: `/users/${uId}/state/${type}`,
    method: "put",
  });
}

//删除用户信息
export function deltUsers(id){
  return request({
    url: `/users/${id}`,
    method: "delete",
  });
}

//分配用户角色
export function setUserRole(id,rid){
  return request({
    url:`/users/${id}`,
    method:'put',
    data:{
      rid
    }
  })
}